﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WeeGODAL;
using Entity.Utity;

namespace WeeGOBLL
{
    public class Movie
    {
        
        //Demo
        //DL里的DLMovie层的Find Data函数
        public static string FindData(int p_Dno)
        {
            DLMovie da=new DLMovie();
            var obj = da.FindData(p_Dno);
            string str = EntityToJSON.ToEntitiesJson(obj,"one");
            return str;
        }

        //影片信息
        //返回json型的影片信息
        /// <summary>
        /// 作者:张晨
        /// 状态：Finished
        /// 调用DLMovie类里的GetMovInfo(int p_MovID)函数
        /// </summary>
        /// <param name="p_MovID"></param>
        /// <returns></returns>
        public static string GetMovInfo(string p_MovID)
        {
            DLMovie dlMovie = new DLMovie();
            var data = dlMovie.GetMovInfo(Int32.Parse(p_MovID));
            string movInfo = EntityToJSON.ToEntitiesJson(data, "movInfo");
            return movInfo;
        }

        //影片简介信息
        //返回json型的MovDesc
        /// <summary>
        /// 作者：张晨
        /// 状态：Finished
        /// 调用DLMovie类里的GetMovDesc(int p_MovID)函数
        /// <param name="p_MovID"></param>
        /// <returns></returns>
        public static string GetMovDesc(string p_MovID)
        {
            DLMovie dlMovie= new DLMovie();
            var data = dlMovie.GetMovDesc(Int32.Parse(p_MovID));
            string desc = EntityToJSON.ToEntitiesJson(data,"desc");
            return desc;
        }

        //预告片
        //返回json型的MovTrailer(预告片链接)
        /// <summary>
        /// 作者：张晨
        /// 状态：Finished
        /// 调用DLMovie里的GetMovTrailer(int p_MovID)函数
        /// </summary>
        /// <param name="p_MovID"></param>
        /// <returns></returns>
        public static string GetMovTrailer(string p_MovID)
        {
            DLMovie dlMovie = new DLMovie();
            var data = dlMovie.GetMovTrailer(Int32.Parse(p_MovID));
            string trailer = EntityToJSON.ToEntitiesJson(data,"trailer");
            return trailer;
        }
        
        
        /// <summary>
        /// 作者：张晨
        /// 状态：Finished
        /// 调用DLMovie类中的GetMovImage(int p_MovID)方法
        /// </summary>
        /// <param name="p_MovID"></param>
        /// <returns>图片url(string)</returns>
        public static string GetMovImage(string p_MovID)
        {
            DLMovie dlMovie = new DLMovie();
            var data = dlMovie.GetMovImage(Int32.Parse(p_MovID));
            string url = EntityToJSON.ToEntitiesJson(data,"url");
            return url;
        }


        //得到MovID
        //返回MovID
        /// <summary>
        /// 作者：张晨
        /// 状态：Finished
        /// 调用Movie类里的GetMovID(string p_MovName)函数
        /// </summary>
        /// <param name="p_MovName"></param>
        /// <returns></returns>
        public static string GetMovID(string p_MovName)
        {
            DLMovie dlMovie = new DLMovie();
            var data = dlMovie.GetMovID(p_MovName);
            string id = EntityToJSON.ToEntitiesJson(data,"id");
            return id;
        }

        //得到显示的MovName
        //返回Json
        /// <summary>
        /// 作者：张晨
        /// 状态：Finished
        /// 调用DLMovie类里的GetMovName()函数
        /// </summary>
        /// <returns></returns>
        public static string GetMovName()
        {
            DLMovie dlMovie = new DLMovie();
            var data = dlMovie.GetMovName();
            string movName = EntityToJSON.ToEntitiesJson(data,"movName");
            return movName;
        }

        //影片搜索
        //根据searchType返回电影信息
        //返回json型的电影信息
        /// <summary>
        /// 作者：张晨
        /// 状态：Finished
        /// 调用DLMovie类里的SearchMov(string p_SearchName, string p_SearchType)函数
        /// </summary>
        /// <param name="p_SearchName"></param>
        /// <param name="p_SearchType"></param>
        /// <returns></returns>
        public static string SearchMov(string p_SearchName, string p_SearchType)
        {
            DLMovie dlMovie = new DLMovie();
            string search=null;
            switch(p_SearchType)
            {
                case "movieName": 
                    { 
                        search = EntityToJSON.ToEntitiesJson(dlMovie.SearchMovByName(p_SearchName),"search"); 
                        break; 
                    }
                case "actor": 
                    { 
                        search = EntityToJSON.ToEntitiesJson(dlMovie.SearchMovByActor(p_SearchName),"search"); 
                        break; 
                    }
                case "director": 
                    { 
                        search = EntityToJSON.ToEntitiesJson(dlMovie.SearchMovByDirector(p_SearchName),"search");
                        break; 
                    }
                case "all": 
                    { 
                        search = EntityToJSON.ToEntitiesJson(dlMovie.SearchMovByALL(p_SearchName), "search"); 
                        break; 
                    }
            }
            return search;
        }


        //影片排序(日期或打分)
        //sortType类型score和date
        //返回json型多部影片信息
        public static string SortMov(string p_SortType)
        {
            return "a";
        }

        //显示首页图片
        //返回json型首页图片地址和影片ID
        public static string ShowImg()
        {
            return "a";
        }
        
    }
}
